package cn.liontalk.demo;

/**
 * @author ZhouZhe
 * @version 1.0
 * @description 可重入粒度测试 递归调用本方法
 * @date 2019-01-27 11:22
 **/
public class SynchronizedRecursion10 {

    static int a = 0;
    static int sum = 0;

    public static void main(String[] args) {
        SynchronizedRecursion10 instance = new SynchronizedRecursion10();
        instance.method();
        System.out.println(sum + "===" + a);
    }

    private synchronized void method() {
        while (a <= 2) {
            sum = sum + a;
            a++;
            method();
        }
    }
}
